package com.dx.mapper.impl;

import com.alibaba.fastjson.JSON;
import com.dx.domain.Grade;
import com.dx.mapper.GradeMapper;
import com.dx.util.MySchoolDbMybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.ArrayList;

/**
 * @ClassName GradeMapperImpl
 * @Description TODO:
 * @Author 12994
 * @Date 2024/10/18 17:34
 * @Version 1.0
 **/
public class GradeMapperImpl implements GradeMapper {
    SqlSession sqlSession;

    @Override
    public ArrayList<Grade> listGradeWithStudentInfo() {

        try {
            sqlSession = MySchoolDbMybatisUtil.getSqlSession();
            return sqlSession.getMapper(GradeMapper.class).listGradeWithStudentInfo();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            MySchoolDbMybatisUtil.releaseSqlSession(sqlSession);
        }
    }

    public static void main(String[] args) {
        new GradeMapperImpl().listGradeWithStudentInfo().forEach(g -> System.out.println(JSON.toJSONString(g)));
    }
}
